<meta charset="utf-8">
   <script>
   $(function () {
	   $.formValidator.initConfig({
		   theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,onSuccess:function(){
				   edit();
			       return false;
			}});
	   $("#loginName").formValidator({onShow:"",onFocus:"会员账号应该为5-16字母、数字或下划线",onCorrect:"输入正确"}).inputValidator({min:5,max:16,onError:"会员账号应该为5-16字母、数字或下划线"}).regexValidator({
		       regExp:"username",dataType:"enum",onError:"会员账号格式错误"
			}).ajaxValidator({
				dataType : "json",
				async : true,
				url : "__ROOT__/index.php/Admin/Users/checkLoginKey/?id={$object.userId}",
				success : function(data){
					var json = WST.toJson(data);
		            if( json.status == "1" ) {
		                return true;
					} else {
		                return false;
					}
					return "该账号已被使用";
				},
				buttons: $("#dosubmit"),
				onError : "该账号已存在。",
				onWait : "请稍候..."
			}).defaultPassed();
		$("#loginPwd").formValidator({
			onShow:"",onFocus:"登录密码长度应该为5-20位之间"
			}).inputValidator({
				min:5,max:50,onError:"登录密码长度应该为5-20位之间"
			}).unFormValidator(true);
		$("#loginPwd").blur(function(){
			  if($("#loginPwd").val()==''){
				  $("#loginPwd").unFormValidator(true);
			  }else{
				  $("#loginPwd").unFormValidator(false);
			  }
		});
   });
   function edit(){
	   var params = {};
	   params.loginName = $.trim($('#loginName').val());
	   params.loginPwd = $.trim($('#loginPwd').val());
	   params.userStatus = $('input[name="userStatus"]:checked').val();
	   params.id = $('#id').val();
	   Plugins.waitTips({title:'信息提示',content:'正在提交数据，请稍后...'});
		$.post("__ROOT__/index.php/Admin/Users/editAccount",params,function(data,textStatus){
			var json = WST.toJson(data);
			if(json.status=='1'){
				Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
				    location.href='__ROOT__/index.php/Admin/Users/queryAccountByPage';
				}});
			}else{
				Plugins.closeWindow();
				Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
			}
		});
   }
   </script>
       <form name="myform" method="post" id="myform">
        <input type='hidden' id='id' value='{$object.userId}'/>
        <table class="table table-hover table-striped table-bordered wst-form">
           <tr>
             <th width='100' align='right'>账号<font color='red'>*</font>：</th>
             <td><input type='text' id='loginName' name='loginName' class="form-control wst-ipt-10" value='{$object.loginName}' maxLength='20'/></td>
           </tr>
           <tr>
             <th width='120' align='right'>密码<font color='red'>*</font>：</th>
             <td>
             <input type='password' id='loginPwd' class="form-control wst-ipt-10" value='{$object.loginPwd}' maxLength='20'/>
             <if condition="$object['userId'] !=0 ">(为空则说明不修改密码)</if></td>
           </tr>  
            <tr>
             <th align='right'>会员状态<font color='red'>*</font>：</th>
             <td>
             <label>
             <input type='radio' id='userStatus1' value='1' name='userStatus' <if condition="$object['userStatus']==1">checked</if>/>启用
             </label>
             <label>
             <input type='radio' id='userStatus0' value='0' name='userStatus' <if condition="$object['userStatus']==0">checked</if>/>停用
             </label>
             </td>
           </tr>
           <tr>
             <td colspan='2' style='padding-left:250px;'>
                 <button type="submit" class="btn btn-success">保&nbsp;存</button>
                 <button type="button" class="btn btn-primary" data-dismiss="modal">返&nbsp;回</button>
             </td>
           </tr>
        </table>
       </form>